Ext.define("Admin.view.decMakConsultation.ProgramDecision", {
    extend: "Admin.common.container.BaseContainer",
    xtype: "programDecision",
    alias: "programDecision",
    requires: [
        "Ext.panel.Panel",
        "Ext.grid.Panel",
        "Ext.button.Button",
        "Admin.common.form.SearchFormPanel",
        "Admin.store.decMakConsultation.ProgramDecisionMeeting"
    ],
    controller: "programDecision",
    height: 200,
    items: [{
        xtype: "panel",
        layout: { type: "vbox", align: "stretch" },
        items: [{
                xtype: "baseGridPanel",
                reference: "meetingGrid",
                title: "历史会商",
                flex: 1,
                cls: "shadow",
                style: "border: 1px solid #ccc",
                columns: [
                    { header: "会商名称", dataIndex: "conName", align: "center", flex: 1 },
                    {
                        header: "会商类型",
                        dataIndex: "conType",
                        align: "center",
                        flex: 1,
                        renderer: function(value) {
                            return getValue('contype', value);
                        }
                    },
                    {
                        header: "推荐方案名称+编号",
                        dataIndex: "recProNm",
                        hidden: true,
                    },
                    {
                        header: "方案编号",
                        dataIndex: "proIdRec",
                        hidden: true,
                    },
                    {
                        header: "推荐方案",
                        dataIndex: "recProNm",
                        align: "center",
                        flex: 1.5,
                        renderer: function(value, record, dataIndex, cell, column) {
                            var a = '',
                                b = '';
                            if (typeof(dataIndex.data.recProNm) !== "undefined") { a = dataIndex.data.recProNm; }
                            if (typeof(dataIndex.data.proIdRec) !== "undefined") { b = dataIndex.data.proIdRec; }
                            return a + b;
                        }
                    },
                    { header: "创建日期", dataIndex: "dt", align: "center", flex: 1 },
                    {
                        xtype: "actioncolumn",
                        // xtype: "actionTextcolumn",
                        text: "操作",
                        align: "center",
                        width: 100,
                        sortable: false,
                        menuDisabled: true,
                        items: [{
                                iconCls: "x-fa fa-edit",
                                tooltip: "编辑",
                                // showText: "编辑",
                                handler: "meetingUpdata"
                            },
                            {
                                iconCls: "x-fa fa-times-circle",
                                tooltip: "删除",
                                // showText: "删除",
                                handler: "meetingDel"
                            },
                            // {
                            //     showText: "上报",
                            //     handler: "del"
                            // },
                            // {
                            //     showText: "审批",
                            //     handler: "del"
                            // }
                        ]
                    }
                ],
                store: {
                    type: "programDecisionMeeting"
                },
                tbar: [{
                        xtype: "searchFormPanel",
                        columns: 4,
                        // layout: 'columns',
                        items: [{
                                xtype: "dicComboBox",
                                dicType: "hslx",
                                fieldLabel: "会商类型",
                                reference: "MEETING_TYPE",
                                // editable: false,
                                emptyText: "请选择会商类型"
                            },
                            {
                                xtype: "textfield",
                                fieldLabel: "会商名称",
                                emptyText: "请输入会商名称",
                                reference: "MEETING_NAME"
                            },
                            // {
                            // 	xtype: "combobox",
                            // 	// maxWidth: 220,
                            // 	fieldLabel: "会商名称",
                            // 	// labelWidth: 80,
                            // 	valueField: "conName",
                            // 	displayField: "conName",
                            // 	reference: "meetingName",
                            // 	listeners: {
                            // 		added: function (combo) {
                            // 			var _that = this;
                            // 			var store = Ext.create("Ext.data.Store", {
                            // 				autoLoad: true,
                            // 				proxy: {
                            // 					type: "ajax",
                            // 					extraParams: { river: config.RIVER },
                            // 					url: config.URL + "szy/dispatch/meeting/ddsSCon/list",
                            // 					reader: {
                            // 						type: "json",
                            // 						rootProperty: "list",
                            // 						fields: ["conName", "conId"]
                            // 					}
                            // 				}
                            // 			});
                            // 			combo.setStore(store);
                            // 			// store.on('endupdate', function () {
                            // 			// 	if (!combo.getValue()) {
                            // 			// 		combo.setValue(store.getAt(0).get('conId'))
                            // 			// 	}
                            // 			// })
                            // 		},
                            // 	}
                            // },
                        ]
                    },
                    "->",
                    {
                        xtype: "button",
                        iconCls: "x-fa fa-search",
                        text: "查询",
                        handler: "meetingSearch"
                    },
                    {
                        xtype: "button",
                        iconCls: "x-fa fa-save",
                        text: "新增",
                        handler: "meetingAdd"
                    },
                ],
                bbar: {
                    xtype: "pagingtoolbar",
                    autoLoad: true,
                    displayInfo: true,
                    displayMsg: "显示从第{0}条数据到第{1}条数据，共{2}条数据",
                    emptyMsg: "没有记录"
                }
            }
            // {
            // 	xtype :'baseFormPanel',
            // 	border:true,
            //   hidden:true,
            // 	title:'新建会商',
            // 	margin : '20 0 0 0',
            // 	columns : 4,
            // 	defLabelWidth : 90,
            // 	items : [{
            // 		xtype: 'dicComboBox',
            // 		dicType : 'hslx',
            // 		fieldLabel : '会商类型'
            // 	},{
            // 		xtype: 'textfield',
            // 		fieldLabel : '会商名称'
            // 	},{
            // 		xtype: 'dicComboBox',
            // 		fieldLabel : '选择备选方案'
            // 	},{
            // 		xtype : 'dicComboBox',
            // 		dicType : 'yxfa',
            // 		fieldLabel: '优先方案'
            // 	}],
            // 	bbar : ['->',{
            // 		xtype : 'button',
            //     iconCls:'x-fa fa-save',
            // 		text: '新建会商',
            // 		handler:'onNewConsultationClick'
            // 	}]
            // }
        ]
    }]
});

//会商 新增/修改 form表单
Ext.define("Admin.view.ProgramDecision.MeetingForm", {
    extend: "Admin.common.form.BaseFormPanel",
    xtype: "meetingForm",
    require: ["Admin.store.emergencyDispatch.NewPlanEventList"],
    alias: "meetingForm",
    bodyPadding: 10,
    anchor: "90%",
    layout: "anchor",
    defaults: {
        anchor: "100%",
        labelWidth: 60,
        labelAlign: "right"
    },
    items: [{
            xtype: "fieldset",
            title: "基本信息",
            defaultType: "textfield",
            layout: "anchor",
            defaults: {
                anchor: "100%"
            },
            items: [{
                    xtype: "textfield",
                    grow: true,
                    name: "conName",
                    fieldLabel: "会商名称",
                    allowBlank: false,
                    anchor: "100%"
                },
                {
                    xtype: "combobox",
                    fieldLabel: "选择应急事件",
                    name: "evenCd",
                    allowBlank: false,
                    valueField: "value",
                    displayField: "label",
                    queryMode: "remote", //数据从服务端读取
                    remoteFilter: true, //进一步过滤store
                    editable: false,
                    listeners: {
                        added: function(combo) {
                            var _that = this;
                            var store = Ext.create("Ext.data.Store", {
                                autoLoad: true,
                                proxy: {
                                    type: "ajax",
                                    extraParams: { river: config.RIVER },
                                    url: config.URL + "emergency/ddsEdEvent/listAll",
                                    reader: {
                                        type: "json",
                                        rootProperty: "list",
                                        fields: ["label", "value"]
                                    }
                                },
                                listeners: {
                                    load: function() {
                                        console.log();
                                    }
                                }
                            });
                            combo.setStore(store);
                        }
                    }
                },
                {
                    xtype: "dicComboBox",
                    dicType: "hslx",
                    fieldLabel: "会商类型",
                    allowBlank: false,
                    // value: "1",
                    editable: false,
                    name: "conType"
                },
                {
                    xtype: "datetimefield",
                    fieldLabel: "创建日期",
                    editable: false,
                    allowBlank: false,
                    name: "dt",
                    flex: 1
                }
            ]
        },
        {
            xtype: "fieldset",
            title: "会议纪要",
            defaultType: "textfield",
            layout: "anchor",
            defaults: {
                anchor: "100%"
            },
            items: [{
                    xtype: "textfield",
                    grow: true,
                    name: "department",
                    fieldLabel: "主持单位",
                    allowBlank: false,
                    anchor: "100%"
                },
                {
                    xtype: "textareafield",
                    grow: true,
                    name: "topics",
                    fieldLabel: "会议主题",
                    allowBlank: false,
                    anchor: "100%"
                },
                {
                    xtype: "htmleditor",
                    enableColors: false,
                    enableAlignments: false,
                    fieldLabel: "会议内容",
                    allowBlank: false,
                    name: "summary"
                }
            ]
        },
        {
            xtype: "textfield",
            name: "conId",
            hidden: true
        }
    ]
});